﻿namespace HRM.CORE.REPORT
{
    using APP.HELPER.Utils.Security;
    using DevExpress.Utils;
    using DevExpress.XtraPrinting;
    using DevExpress.XtraReports.UI;
    using HRM.CORE;
    using HRM.CORE.CLASS;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Printing;

    public class rptListAdvanceByEmployee : XtraReport
    {
        private BottomMarginBand BottomMargin;
        private IContainer components;
        private int count;
        private DetailBand Detail;
        private GroupHeaderBand GroupHeader1;
        private HRM_PROCESS_ADVANCE l_Advance;
        private string m_EmployeeCode;
        private DateTime m_FromDate;
        private DateTime m_ToDate;
        private XRPictureBox ptLogo;
        private XRPictureBox ptPhoto;
        private ReportFooterBand ReportFooter;
        private ReportHeaderBand ReportHeader;
        private TopMarginBand TopMargin;
        private XRLabel txtCompany;
        private XRLabel txtEmployeeCode;
        private XRLabel txtEmployeeName;
        private XRLabel txtPosition;
        private XRLabel txtTime;
        private XRTableCell xrCellDecideNumber;
        private XRTableCell xrCellReason;
        private XRTableCell xrCelNumeric;
        private XRLabel xrLabel1;
        private XRLabel xrLabel2;
        private XRLabel xrLabel3;
        private XRLabel xrLabel4;
        private XRLabel xrLabel7;
        private XRTableCell xrTableCell1;
        private XRTableCell xrTableCell2;
        private XRTableCell xrTableCell3;
        private XRTableCell xrTableCell4;
        private XRTableRow xrTableRow1;
        private XRTableRow xrTableRow2;
        private XRTable xrTblReward;
        private XRTableCell xrTblRewardCell1;
        private XRTableCell xrTblRewardCell2;
        private XRTableCell xrTblRewardCell4;
        private XRTable xrTblRewardTitle;

        public rptListAdvanceByEmployee(string EmployeeCode)
        {
            this.count = 0;
            this.m_EmployeeCode = "";
            this.m_FromDate = DateTime.Now;
            this.m_ToDate = DateTime.Now;
            this.l_Advance = new HRM_PROCESS_ADVANCE();
            this.components = null;
            this.m_EmployeeCode = EmployeeCode;
            this.InitializeComponent();
            this.LoadData();
        }

        public rptListAdvanceByEmployee(string EmployeeCode, DateTime FromDate, DateTime ToDate)
        {
            this.count = 0;
            this.m_EmployeeCode = "";
            this.m_FromDate = DateTime.Now;
            this.m_ToDate = DateTime.Now;
            this.l_Advance = new HRM_PROCESS_ADVANCE();
            this.components = null;
            this.InitializeComponent();
            this.m_EmployeeCode = EmployeeCode;
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
            this.txtTime.Text = "(Từ ng\x00e0y " + this.m_FromDate.ToShortDateString() + " đến ng\x00e0y " + this.m_ToDate.ToShortDateString() + ")";
            this.LoadDataByDate();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.Detail = new DetailBand();
            this.xrTblReward = new XRTable();
            this.xrTableRow2 = new XRTableRow();
            this.xrCelNumeric = new XRTableCell();
            this.xrCellDecideNumber = new XRTableCell();
            this.xrCellReason = new XRTableCell();
            this.xrTableCell2 = new XRTableCell();
            this.xrTableCell4 = new XRTableCell();
            this.xrTblRewardTitle = new XRTable();
            this.xrTableRow1 = new XRTableRow();
            this.xrTblRewardCell1 = new XRTableCell();
            this.xrTblRewardCell2 = new XRTableCell();
            this.xrTblRewardCell4 = new XRTableCell();
            this.xrTableCell1 = new XRTableCell();
            this.xrTableCell3 = new XRTableCell();
            this.TopMargin = new TopMarginBand();
            this.BottomMargin = new BottomMarginBand();
            this.xrLabel1 = new XRLabel();
            this.ptLogo = new XRPictureBox();
            this.ReportHeader = new ReportHeaderBand();
            this.ptPhoto = new XRPictureBox();
            this.xrLabel2 = new XRLabel();
            this.txtEmployeeCode = new XRLabel();
            this.xrLabel4 = new XRLabel();
            this.xrLabel3 = new XRLabel();
            this.txtPosition = new XRLabel();
            this.txtEmployeeName = new XRLabel();
            this.txtCompany = new XRLabel();
            this.txtTime = new XRLabel();
            this.xrLabel7 = new XRLabel();
            this.GroupHeader1 = new GroupHeaderBand();
            this.ReportFooter = new ReportFooterBand();
            this.xrTblReward.BeginInit();
            this.xrTblRewardTitle.BeginInit();
            this.BeginInit();
            this.Detail.Controls.AddRange(new XRControl[] { this.xrTblReward });
            this.Detail.HeightF = 23.74996f;
            this.Detail.Name = "Detail";
            this.Detail.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.Detail.TextAlignment = TextAlignment.TopLeft;
            this.xrTblReward.Borders = BorderSide.Bottom | BorderSide.Right | BorderSide.Left;
            this.xrTblReward.LocationFloat = new PointFloat(0f, 0f);
            this.xrTblReward.Name = "xrTblReward";
            this.xrTblReward.Rows.AddRange(new XRTableRow[] { this.xrTableRow2 });
            this.xrTblReward.SizeF = new SizeF(996.0001f, 23.74996f);
            this.xrTblReward.StylePriority.UseBorders = false;
            this.xrTblReward.StylePriority.UseTextAlignment = false;
            this.xrTblReward.TextAlignment = TextAlignment.MiddleCenter;
            this.xrTableRow2.Cells.AddRange(new XRTableCell[] { this.xrCelNumeric, this.xrCellDecideNumber, this.xrCellReason, this.xrTableCell2, this.xrTableCell4 });
            this.xrTableRow2.Name = "xrTableRow2";
            this.xrTableRow2.Weight = 1.0;
            this.xrCelNumeric.Font = new Font("Times New Roman", 11.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.xrCelNumeric.Name = "xrCelNumeric";
            this.xrCelNumeric.StylePriority.UseFont = false;
            this.xrCelNumeric.StylePriority.UseTextAlignment = false;
            this.xrCelNumeric.TextAlignment = TextAlignment.MiddleCenter;
            this.xrCelNumeric.Weight = 0.22703619887183102;
            this.xrCelNumeric.BeforePrint += new PrintEventHandler(this.xrCelNumeric_BeforePrint);
            this.xrCellDecideNumber.Font = new Font("Times New Roman", 11.25f);
            this.xrCellDecideNumber.Name = "xrCellDecideNumber";
            this.xrCellDecideNumber.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.xrCellDecideNumber.StylePriority.UseFont = false;
            this.xrCellDecideNumber.StylePriority.UsePadding = false;
            this.xrCellDecideNumber.StylePriority.UseTextAlignment = false;
            this.xrCellDecideNumber.Text = "[Date!dd/MM/yyyy]";
            this.xrCellDecideNumber.TextAlignment = TextAlignment.MiddleCenter;
            this.xrCellDecideNumber.Weight = 0.78618885741684119;
            this.xrCellReason.Font = new Font("Times New Roman", 11.25f);
            this.xrCellReason.Name = "xrCellReason";
            this.xrCellReason.Padding = new PaddingInfo(4, 0, 0, 0, 100f);
            this.xrCellReason.StylePriority.UseFont = false;
            this.xrCellReason.StylePriority.UsePadding = false;
            this.xrCellReason.StylePriority.UseTextAlignment = false;
            this.xrCellReason.Text = "[Reason]";
            this.xrCellReason.TextAlignment = TextAlignment.MiddleLeft;
            this.xrCellReason.Weight = 0.81129795986999165;
            this.xrTableCell2.Font = new Font("Times New Roman", 11.25f);
            this.xrTableCell2.Name = "xrTableCell2";
            this.xrTableCell2.Padding = new PaddingInfo(0, 4, 0, 0, 100f);
            this.xrTableCell2.StylePriority.UseFont = false;
            this.xrTableCell2.StylePriority.UsePadding = false;
            this.xrTableCell2.StylePriority.UseTextAlignment = false;
            this.xrTableCell2.Text = "[Money!#,0]";
            this.xrTableCell2.TextAlignment = TextAlignment.MiddleRight;
            this.xrTableCell2.Weight = 0.82827326117794053;
            this.xrTableCell4.Font = new Font("Times New Roman", 11.25f);
            this.xrTableCell4.Name = "xrTableCell4";
            this.xrTableCell4.StylePriority.UseFont = false;
            this.xrTableCell4.Text = "[Person]";
            this.xrTableCell4.Weight = 0.96947688019651046;
            this.xrTblRewardTitle.BackColor = Color.Silver;
            this.xrTblRewardTitle.Borders = BorderSide.All;
            this.xrTblRewardTitle.Font = new Font("Times New Roman", 11.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.xrTblRewardTitle.LocationFloat = new PointFloat(0f, 0f);
            this.xrTblRewardTitle.Name = "xrTblRewardTitle";
            this.xrTblRewardTitle.Rows.AddRange(new XRTableRow[] { this.xrTableRow1 });
            this.xrTblRewardTitle.SizeF = new SizeF(996.0001f, 39.58333f);
            this.xrTblRewardTitle.StylePriority.UseBackColor = false;
            this.xrTblRewardTitle.StylePriority.UseBorders = false;
            this.xrTblRewardTitle.StylePriority.UseFont = false;
            this.xrTblRewardTitle.StylePriority.UseTextAlignment = false;
            this.xrTblRewardTitle.TextAlignment = TextAlignment.MiddleCenter;
            this.xrTableRow1.Cells.AddRange(new XRTableCell[] { this.xrTblRewardCell1, this.xrTblRewardCell2, this.xrTblRewardCell4, this.xrTableCell1, this.xrTableCell3 });
            this.xrTableRow1.Name = "xrTableRow1";
            this.xrTableRow1.Weight = 1.0;
            this.xrTblRewardCell1.Name = "xrTblRewardCell1";
            this.xrTblRewardCell1.Text = "STT";
            this.xrTblRewardCell1.Weight = 0.22703640602313807;
            this.xrTblRewardCell2.Name = "xrTblRewardCell2";
            this.xrTblRewardCell2.Text = "Ng\x00e0y ứng";
            this.xrTblRewardCell2.Weight = 0.78618850526952277;
            this.xrTblRewardCell4.Name = "xrTblRewardCell4";
            this.xrTblRewardCell4.Text = "L\x00fd do ứng tiền";
            this.xrTblRewardCell4.Weight = 0.81129784983052211;
            this.xrTableCell1.Name = "xrTableCell1";
            this.xrTableCell1.Text = "Số tiền";
            this.xrTableCell1.Weight = 0.82827285861121114;
            this.xrTableCell3.Name = "xrTableCell3";
            this.xrTableCell3.Text = "Người cho ứng";
            this.xrTableCell3.Weight = 0.96947696605536637;
            this.TopMargin.HeightF = 46f;
            this.TopMargin.Name = "TopMargin";
            this.TopMargin.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.TopMargin.TextAlignment = TextAlignment.TopLeft;
            this.BottomMargin.HeightF = 51f;
            this.BottomMargin.Name = "BottomMargin";
            this.BottomMargin.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.BottomMargin.TextAlignment = TextAlignment.TopLeft;
            this.xrLabel1.Font = new Font("Times New Roman", 18f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.xrLabel1.LocationFloat = new PointFloat(222.9167f, 25.91664f);
            this.xrLabel1.Name = "xrLabel1";
            this.xrLabel1.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel1.SizeF = new SizeF(773.0835f, 31.70829f);
            this.xrLabel1.StylePriority.UseFont = false;
            this.xrLabel1.StylePriority.UseTextAlignment = false;
            this.xrLabel1.Text = "SỔ THEO D\x00d5I TẠM ỨNG LƯƠNG";
            this.xrLabel1.TextAlignment = TextAlignment.MiddleCenter;
            this.ptLogo.LocationFloat = new PointFloat(47.66667f, 0f);
            this.ptLogo.Name = "ptLogo";
            this.ptLogo.SizeF = new SizeF(109.375f, 72.91665f);
            this.ptLogo.Sizing = ImageSizeMode.StretchImage;
            this.ReportHeader.Controls.AddRange(new XRControl[] { this.ptPhoto, this.xrLabel2, this.txtEmployeeCode, this.xrLabel4, this.xrLabel3, this.txtPosition, this.txtEmployeeName, this.txtCompany, this.txtTime, this.xrLabel1, this.ptLogo, this.xrLabel7 });
            this.ReportHeader.HeightF = 199f;
            this.ReportHeader.Name = "ReportHeader";
            this.ptPhoto.BorderColor = Color.Gainsboro;
            this.ptPhoto.Borders = BorderSide.All;
            this.ptPhoto.LocationFloat = new PointFloat(47.66668f, 115.625f);
            this.ptPhoto.Name = "ptPhoto";
            this.ptPhoto.SizeF = new SizeF(94.63295f, 76.375f);
            this.ptPhoto.Sizing = ImageSizeMode.ZoomImage;
            this.ptPhoto.StylePriority.UseBorderColor = false;
            this.ptPhoto.StylePriority.UseBorders = false;
            this.xrLabel2.BorderColor = Color.Black;
            this.xrLabel2.Font = new Font("Times New Roman", 12f);
            this.xrLabel2.LocationFloat = new PointFloat(160.1667f, 115.625f);
            this.xrLabel2.Name = "xrLabel2";
            this.xrLabel2.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel2.SizeF = new SizeF(105.6993f, 20f);
            this.xrLabel2.StylePriority.UseBorderColor = false;
            this.xrLabel2.StylePriority.UseFont = false;
            this.xrLabel2.StylePriority.UseTextAlignment = false;
            this.xrLabel2.Text = "M\x00e3 nh\x00e2n vi\x00ean:";
            this.xrLabel2.TextAlignment = TextAlignment.MiddleLeft;
            this.txtEmployeeCode.BorderColor = Color.Black;
            this.txtEmployeeCode.Font = new Font("Times New Roman", 12f, FontStyle.Bold);
            this.txtEmployeeCode.LocationFloat = new PointFloat(272.6667f, 115.625f);
            this.txtEmployeeCode.Name = "txtEmployeeCode";
            this.txtEmployeeCode.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtEmployeeCode.SizeF = new SizeF(356.0985f, 20.00001f);
            this.txtEmployeeCode.StylePriority.UseBorderColor = false;
            this.txtEmployeeCode.StylePriority.UseFont = false;
            this.txtEmployeeCode.StylePriority.UseTextAlignment = false;
            this.txtEmployeeCode.Text = "txtEmployeeCode";
            this.txtEmployeeCode.TextAlignment = TextAlignment.MiddleLeft;
            this.xrLabel4.BorderColor = Color.Black;
            this.xrLabel4.Font = new Font("Times New Roman", 12f);
            this.xrLabel4.LocationFloat = new PointFloat(160.1667f, 165.625f);
            this.xrLabel4.Name = "xrLabel4";
            this.xrLabel4.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel4.SizeF = new SizeF(76.79761f, 20f);
            this.xrLabel4.StylePriority.UseBorderColor = false;
            this.xrLabel4.StylePriority.UseFont = false;
            this.xrLabel4.StylePriority.UseTextAlignment = false;
            this.xrLabel4.Text = "Chức vụ:";
            this.xrLabel4.TextAlignment = TextAlignment.MiddleLeft;
            this.xrLabel3.BorderColor = Color.Black;
            this.xrLabel3.Font = new Font("Times New Roman", 12f);
            this.xrLabel3.LocationFloat = new PointFloat(160.1667f, 140.625f);
            this.xrLabel3.Name = "xrLabel3";
            this.xrLabel3.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel3.SizeF = new SizeF(64.29764f, 20f);
            this.xrLabel3.StylePriority.UseBorderColor = false;
            this.xrLabel3.StylePriority.UseFont = false;
            this.xrLabel3.StylePriority.UseTextAlignment = false;
            this.xrLabel3.Text = "Họ t\x00ean:";
            this.xrLabel3.TextAlignment = TextAlignment.MiddleLeft;
            this.txtPosition.Font = new Font("Times New Roman", 12f, FontStyle.Bold);
            this.txtPosition.LocationFloat = new PointFloat(240.1667f, 165.625f);
            this.txtPosition.Name = "txtPosition";
            this.txtPosition.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtPosition.SizeF = new SizeF(387.4584f, 20f);
            this.txtPosition.StylePriority.UseFont = false;
            this.txtPosition.StylePriority.UseTextAlignment = false;
            this.txtPosition.Text = "txtPosition";
            this.txtPosition.TextAlignment = TextAlignment.MiddleLeft;
            this.txtEmployeeName.Font = new Font("Times New Roman", 12f, FontStyle.Bold);
            this.txtEmployeeName.LocationFloat = new PointFloat(227.6667f, 140.625f);
            this.txtEmployeeName.Name = "txtEmployeeName";
            this.txtEmployeeName.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtEmployeeName.SizeF = new SizeF(399.9584f, 19.99989f);
            this.txtEmployeeName.StylePriority.UseFont = false;
            this.txtEmployeeName.StylePriority.UseTextAlignment = false;
            this.txtEmployeeName.Text = "txtEmployeeName";
            this.txtEmployeeName.TextAlignment = TextAlignment.MiddleLeft;
            this.txtCompany.Font = new Font("Times New Roman", 12f, FontStyle.Bold);
            this.txtCompany.LocationFloat = new PointFloat(0f, 72.91663f);
            this.txtCompany.Name = "txtCompany";
            this.txtCompany.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtCompany.SizeF = new SizeF(202.6248f, 21.29163f);
            this.txtCompany.StylePriority.UseFont = false;
            this.txtCompany.StylePriority.UseTextAlignment = false;
            this.txtCompany.Text = "Company";
            this.txtCompany.TextAlignment = TextAlignment.MiddleCenter;
            this.txtTime.Font = new Font("Times New Roman", 12f, FontStyle.Italic, GraphicsUnit.Point, 0);
            this.txtTime.LocationFloat = new PointFloat(222.9167f, 57.62494f);
            this.txtTime.Name = "txtTime";
            this.txtTime.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtTime.SizeF = new SizeF(773.0835f, 21.29159f);
            this.txtTime.StylePriority.UseFont = false;
            this.txtTime.StylePriority.UseTextAlignment = false;
            this.txtTime.TextAlignment = TextAlignment.MiddleCenter;
            this.xrLabel7.ForeColor = Color.Silver;
            this.xrLabel7.LocationFloat = new PointFloat(47.66668f, 147.125f);
            this.xrLabel7.Name = "xrLabel7";
            this.xrLabel7.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel7.SizeF = new SizeF(94.63295f, 17.70833f);
            this.xrLabel7.StylePriority.UseForeColor = false;
            this.xrLabel7.StylePriority.UseTextAlignment = false;
            this.xrLabel7.Text = "Ảnh";
            this.xrLabel7.TextAlignment = TextAlignment.MiddleCenter;
            this.GroupHeader1.Controls.AddRange(new XRControl[] { this.xrTblRewardTitle });
            this.GroupHeader1.HeightF = 39.58334f;
            this.GroupHeader1.Name = "GroupHeader1";
            this.ReportFooter.HeightF = 23f;
            this.ReportFooter.Name = "ReportFooter";
            base.Bands.AddRange(new Band[] { this.Detail, this.TopMargin, this.BottomMargin, this.ReportHeader, this.GroupHeader1, this.ReportFooter });
            base.Landscape = true;
            base.Margins = new Margins(0x65, 0x48, 0x2e, 0x33);
            base.PageHeight = 0x33b;
            base.PageWidth = 0x491;
            base.PaperKind = PaperKind.A4;
            base.Version = "9.3";
            this.BeforePrint += new PrintEventHandler(this.rptListAdvance_BeforePrint);
            this.xrTblReward.EndInit();
            this.xrTblRewardTitle.EndInit();
            this.EndInit();
        }

        private void LoadData()
        {
            DataSet set = new DataSet();
            DataTable listByEmployee = new DataTable();
            listByEmployee = this.l_Advance.GetListByEmployee(this.m_EmployeeCode);
            set.Tables.Add(listByEmployee);
            base.DataSource = set;
            base.DataMember = listByEmployee.TableName;
            base.DataAdapter = listByEmployee;
        }

        private void LoadDataByDate()
        {
            DataSet set = new DataSet();
            DataTable table = new DataTable();
            table = this.l_Advance.GetListByDays(this.m_EmployeeCode, this.m_FromDate, this.m_ToDate);
            set.Tables.Add(table);
            base.DataSource = set;
            base.DataMember = table.TableName;
            base.DataAdapter = table;
        }

        private void rptListAdvance_BeforePrint(object sender, PrintEventArgs e)
        {
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            this.ptPhoto.Image = hrm_employee.Photo;
            this.txtEmployeeCode.Text = hrm_employee.EmployeeCode;
            this.txtEmployeeName.Text = hrm_employee.FirstName + " " + hrm_employee.LastName;
            this.txtPosition.Text = hrm_employee.Position;
            ////if (MyInfo.Get(MyEncryption.Encrypt("ERP01", "123654", true)) == "OK")
            {
                this.ptLogo.Image = null;//MyInfo.Photo;
                this.txtCompany.Text = "";//MyInfo.Company;
            }
            CreateFooterReport.CreateFooter("IsOther", this.ReportFooter, this);
        }

        private void xrCelNumeric_BeforePrint(object sender, PrintEventArgs e)
        {
            this.count++;
            this.xrCelNumeric.Text = this.count.ToString();
        }
    }
}

